<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>      
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>   

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<c:choose>
	 <c:when test="${os eq 'wechat'|| os eq 'web'}">
	 	<link rel="stylesheet"  href="${host_url}/css/app/common.css"> 
		<link rel="stylesheet"  href="${host_url}/css/app/coupon_details.css"> 
		<link rel="stylesheet"  href="${host_url}/css/app/dropload.css">
		<script src="${host_url}/js/app/jquery.min.js"></script>
	 	<script src="${host_url}/js/app/commonForWe.js"></script>
	 	<script src="${host_url}/js/app/dropload.min.js"></script>
	 </c:when>
	 <c:otherwise>
		<link rel="stylesheet"  href="/css/app/common.css">
		<link rel="stylesheet"  href="/css/app/coupon_details.css">
		<link rel="stylesheet"  href="/css/app/dropload.css"> 
		<script src="/js/app/jquery.min.js"></script>
		<script src="/js/app/common.js"></script>
		<script src="/js/app/dropload.min.js"></script>
	 </c:otherwise>
</c:choose>

<script type="text/javascript">
  document.getElementsByTagName('html')[0].style.fontSize = document.documentElement.clientWidth/50 + 'px';
</script>
<script type="text/javascript">
var os="${os}";
<c:if test="${os=='wechat'||os=='web'}">
	
	function getList(type,bill_type){
			$.ajax({
				type:"GET", 	
				url:'buyCashScreenData.do?type='+type+"&bill_type="+bill_type,	 		

				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					$("#we_body").empty().append(data);
					var page_index_select = 2;	/* 筛选 */
					loadPagination("listSelect",page_index_select,"logSelect",bill_type,type);
				 },	 
			});
		}
		
		$(function(){
			$.ajax({
				type:"GET", 	
				url:'buyCashScreenItem.do?bill_type=2',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logIn").html(data);  
					}else{
						$("#listInBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
			
			$.ajax({
				type:"GET", 	
				url:'buyCashScreenItem.do?bill_type=1',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logOut").html(data);  
					}else{
						$("#listOutBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
		});
		
		

	$(function(){
		/* 页数 */
		var page_index_all = 2; /* 全部 */
		var page_index_in = 2;	/* 收入 */
		var page_index_out = 2;	/* 支出 */
		
	    /* dropload 加载分页 */
	    loadPagination("listAll",page_index_all,"logAll","","");
	    loadPagination("listIn",page_index_in,"logIn",2,"");
	    loadPagination("listOut",page_index_out,"logOut",1,"");
	});	

	function loadPagination(div_id, page_index, ul_id, bill_type, type){
		$('#'+div_id).dropload({
	        scrollArea : window,
	        loadDownFn : function(me){
	            $.ajax({
	                type: 'get',
	                url: 'buyCashScreenItem.do?page_index='+page_index+"&bill_type="+bill_type+"&type="+type,
	                dataType: 'text',
	                beforeSend: function(request) {
	    				request.setRequestHeader("AUTHORIZATION","${token}");
	    				request.setRequestHeader("SECRET","${memberId}");
	    				request.setRequestHeader("OS","${os}");
	    			 }, 
	                contentType:"application/x-www-form-urlencoded; charset=UTF-8",
	                success: function(msg){
	                    if($.trim(msg)){
	                		page_index++;
	                    	$("#"+ul_id).append(msg);
	                    	me.resetload();
	                    	/* 如果没有数据 */
	                    } else{
	                       	/* 锁定 */
	                        me.lock();
	                        	/* 无数据 */
	                        me.noData();
	                        $("#"+div_id+" .dropload-load").html("");
	                    } 
	                },
		                error: function(xhr, type){
	                   /*  即使加载出错，也得重置 */
	                    me.resetload();
	                } 
	            });
	        }
	    });
	}
	 </c:if>
	 <c:if test="${os=='ios'|| os=='android'}">
	/* ios  android */
	function GetToken(id){
		  var buycashone_url = $("#buycashone_url").val();
		window.webkit.messageHandlers.ios_open_page.postMessage('WKViewController:::url->'+buycashone_url+'?logByCashId='+id+':::webTitle->交易明细:::isRefresh->YES');
	}

	function getList(type,bill_type){
			$.ajax({
				type:"GET", 	
				url:'buyCashScreen?type='+type+"&bill_type="+bill_type,	 		

				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					$("body").html(data);  
					var page_index_select = 2;	/* 筛选 */
					loadPagination("listSelect",page_index_select,"logSelect",bill_type,type);
				 },	 
			});
		}
		
		$(function(){
			$.ajax({
				type:"GET", 	
				url:'buyCashScreenItem?bill_type=2',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logIn").html(data);  
					}else{
						$("#listInBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
			
			$.ajax({
				type:"GET", 	
				url:'buyCashScreenItem?bill_type=1',	 		
				beforeSend: function(request) {
					request.setRequestHeader("AUTHORIZATION","${token}");
					request.setRequestHeader("SECRET","${memberId}");
					request.setRequestHeader("OS","${os}");
				 }, 
				success: function (data) {
					if($.trim(data)){
						$("#logOut").html(data);  
					}else{
						$("#listOutBlank").html('<div class="zanwu"> <span><img src="/img/app/zanwu.png"></span> <p>暂无记录</p> </div>');
					}
				 },	 
			});
		});
		
		

	$(function(){
		/* 页数 */
		var page_index_all = 2; /* 全部 */
		var page_index_in = 2;	/* 收入 */
		var page_index_out = 2;	/* 支出 */
		
	    /* dropload 加载分页 */
	    loadPagination("listAll",page_index_all,"logAll","","");
	    loadPagination("listIn",page_index_in,"logIn",2,"");
	    loadPagination("listOut",page_index_out,"logOut",1,"");
	});	

	function loadPagination(div_id, page_index, ul_id, bill_type, type){
		$('#'+div_id).dropload({
	        scrollArea : window,
	        loadDownFn : function(me){
	            $.ajax({
	                type: 'get',
	                url: 'buyCashScreenItem.do?page_index='+page_index+"&bill_type="+bill_type+"&type="+type,
	                dataType: 'text',
	                beforeSend: function(request) {
	    				request.setRequestHeader("AUTHORIZATION","${token}");
	    				request.setRequestHeader("SECRET","${memberId}");
	    				request.setRequestHeader("OS","${os}");
	    			 }, 
	                contentType:"application/x-www-form-urlencoded; charset=UTF-8",
	                success: function(msg){
	                    if($.trim(msg)){
	                		page_index++;
	                    	$("#"+ul_id).append(msg);
	                    	me.resetload();
	                    	/* 如果没有数据 */
	                    } else{
	                       	/* 锁定 */
	                        me.lock();
	                        	/* 无数据 */
	                        me.noData();
	                        $("#"+div_id+" .dropload-load").html("");
	                    } 
	                },
		                error: function(xhr, type){
	                   /*  即使加载出错，也得重置 */
	                    me.resetload();
	                } 
	            });
	        }
	    });
	}
	function fn_heleppage() {
		android.startUrl('使用帮助','${buycashheleppage_url}');
	}
	</c:if>

</script>
<title>抵用金明细</title>
</head>
<body>
<c:if test="${'wechat'==os ||'web'==os}">
	<div id="we_body">
</c:if>
	<input type="hidden" id="buycashheleppage_url" value="${buycashheleppage_url}" />
	<input type="hidden"  id="buycashone_url" value="${buycashone_url }" />
	    <div id="main">
	        <div class="tab">
	            <ul class="menu-group-center">
	                <li class="on">全部</li>
	                <li>收入</li>
	                <li>支出</li>
	                <p class="btn-popup"><span class="btn-popup">筛选</span></p>
	            </ul>
	            <div class="content" id="listAll">
	                <ul class="inner" id="logAll">
		                <c:forEach items="${logBuyCashScreenList}" var="c">
						   
						   <c:if test="${'ios'==os}">
						   		<li class="clearfix" onclick="GetToken(${c.logByCashId})">
				           </c:if>
						   <c:if test="${'wechat'==os ||'web'==os}">
						   		<li class="clearfix" onclick="GetDetail('${c.logByCashId}')">
				           </c:if>
				    	   <c:if test="${'android'==os}">
				            	<li class="clearfix" onclick="android.startUrl('交易明细','${buycashone_url}','logByCashId->${c.logByCashId}')">
				           </c:if>
						        <p class="leftArea">
						        	<c:if test="${c.type==1 }"><span>来自于${c.award_name}</span><br></c:if>
						        	<c:if test="${c.type==2 }"><span>退款</span><br></c:if>
						        	<c:if test="${c.type==3 }"><span>购物&nbsp;(订单号：${c.order_no})</span><br></c:if>
						        	<fmt:parseDate value=" ${c.create_time}" var="date" pattern="yyyy-MM-dd HH:mm:ss"/>  
			  						<span><fmt:formatDate value="${date}" pattern="yyyy-MM-dd HH:mm" /></span>
						        </p>
						        <p class="rightArea <c:if test="${c.bill_type == 2 }">col-arresting</c:if>">
						         <c:if test="${c.bill_type == 1 }">-</c:if>
						         <c:if test="${c.bill_type == 2 }">+</c:if>
						         ${c.buy_cash}
						        </p>
						    </li>
						</c:forEach> 
	                </ul>
	                <c:if test="${logBuyCashScreenList.size()==0}">
						<div class="zanwu">
							  <span><img src="${host_url}/img/app/zanwu.png"></span>
							  <p>暂无记录</p>
						</div>
					</c:if> 
	            </div>
	 			<div class="content"  id="listIn" style="display: none;"><ul id="logIn"></ul>
		 			<div id="listInBlank">
						 
					</div>
	 			</div>        
	            <div class="content"  id="listOut" style="display: none;"><ul id="logOut"></ul>
		            <div id="listOutBlank">
						   
					</div>
	            </div>
	        </div>
	    </div>
		<div class="bg-popup"></div>
	    <div id="popup">
	        <div class="popup-content">
	            <div class="clearfix"><h4 class="leftArea"><span>请选择您要筛选的分类</span></h4><p class="rightArea"><span>筛选</span></p></div>
	            <ul class=" one whole common ">
	                <li class="whole-one"><span>全部</span></li>
	                <li><span>收入</span></li>
	                <li><span>支出</span></li>
	            </ul>
	             <ul class="show-content">
		           		<li class="whole-one" onclick="getList('','')"><span>全部</span></li>
		           		<li class="whole-two" onclick="getList('',2)" ><span>收入</span></li>
		           		<li class="whole-there" onclick="getList('',1)"><span>支出</span></li>
	            </ul>
	             <ul class="show-content">
		                <li class="whole-one" onclick="getList(1,2)"><span>奖励分配</span></li> 
		            	<li class="whole-one" onclick="getList(2,2)"><span>退款</span></li>
	            </ul>
	            <ul class="show-content">
		            	<li class="whole-one" onclick="getList(3,1)"><span>购物</span></li>
	            </ul>
	        </div>
	    </div> 
<c:if test="${'wechat'==os ||'web'==os}">
	</div>
</c:if>
</body>
</html>